
Use it to detect vehicles crossing a line, intruders in your space, and much more!
Watch this video for a complete tutorial:
Position the IR LED and the IR sensor so they face each other:
Wire up as follows, using the Edge Connector or Motor Controller board:
Sensor | Microbit |
---|---|
Sensor (with 3 wires) | P13 |
LED (with 2 wires) | Any GND and 3V3 pins, e.g on P7 |
You don't have to use pin P13. You can use any digital pin. Just remember to adjust your code accordingly.
Enter this code in on start:
Enter this code in forever:
Download the code to the microbit.
Test with the beam unbroken (you should see a cross) and broken (you should see a tick):
Note: Using the sensor in bright sunlight can lead to false readings.